<table class="member-grid">
  <thead>
    <tr>
      <!-- <th><input type="checkbox" id="box" value="" ><{t}>选择支付<{/t}></th> --><!--add checkbox by wenlong 全选复选框-->
       <th><input type="checkbox" id="box" value="" style="visibility:hidden"><{t}>商品名称<{/t}></th><!--add checkbox by wenlong 隐藏全选复选框-->
      <th><{t}>订单号<{/t}></th>
      <th><{t}>金额<{/t}></th>
      <th><{t}>下单时间<{/t}></th>
      <th><{t}>订单状态<{/t}></th>
      <th><{t}>支付方式<{/t}></th>
      <th><{t}>操作<{/t}></th>
    </tr>
  </thead>
<!--****************-add by wenlong**********************-->
<!--合并付款按钮-->
<!-- <a href="javascript:void(0);" onclick="pay_total()" class="btn btn-import" style="color: #fff;"><span><span><{t}>合并付款<{/t}></span></span></a> -->
<!--****************************************************-->
  <{if $orders}>
  <{foreach from=$orders item=order name=orders key="key"}>
  <tbody class="<{if !$is_orders}>fold<{else}>unfold<{/if}><{if $smarty.foreach.orders.iteration == 1}> first<{/if}>">
    <tr>
<!--******************add by wenlong********************-->
<!--合并付款勾选框-->
      <td class="chose_pay"><{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==0 && $order.pay_status==0 && $order.status!='dead' && $order.promotion_type != 'prepare'}><input type="checkbox" name="id" value="<{$order.order_id}>" style="visibility:hidden"><{/if}></td>
<!--****************************************************-->
      <td class="order" width="28%"><a href="<{link app=b2c ctl=site_member act=orderdetail arg0=$order.order_id arg1=$archive}>"><{$order.order_id}></a><span class="">[<{$order.itemnum}> <{t}>商品<{/t}>]</span></td>
      <td class="price"><{$order.cur_amount|cur_odr:$order.currency:false:true}></td>
      <td class="datetime"><{$order.createtime|cdate:FDATE_STIME}></td>
      <td class="status">
        <{switch from=$order.status}>
        <{case value='finish'}><{t}>已完成<{/t}>
        <{case value='dead'}><{t}>已作废<{/t}>
        <{case}>
        <{switch from=$order.pay_status}>
        <{case value='1'}><{t}>已付款<{/t}>
        <{switch from=$order.ship_status}>
        <{case value='1'}><{t}>[已发货]<{/t}>
	<{switch from=$order.received_status}><!--add by wenlong-->
	<{case value='1'}><{t}>[已收货]<{/t}><!--add by wenlong-->
	<{/switch}><!--add by wenlong-->
        <{case value='2'}><{t}>[部分发货]<{/t}> 
        <{switch from=$order.received_status}><!--add by wenlong-->
        <{case value='2'}><{t}>[部分收货]<{/t}><!--add by wenlong-->
        <{/switch}><!--add by wenlong-->
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{case}><{t}>[正在备货]<{/t}>
        <{/switch}>
        <{case value='2'}><{t}>已付款至担保方<{/t}>
        <{case value='3'}>
         <!--普通订单-->
        <{if $order.promotion_type != 'prepare'}>
          <a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>"><{t}>等待补款<{/t}></a>
        <{/if}>
         <!--预售订单-->
        <{if  $order.promotion_type == 'prepare'}>
        <a href="#"><{t}>等待补款<{/t}></a>
        <{/if}>
        <{switch from=$order.ship_status}>
        <{case value='1'}><{t}>[已发货]<{/t}>
        <{case value='2'}><{t}>[部分发货]<{/t}>
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{/switch}>
        <{case value='4'}><{t}>部分退款<{/t}>
        <{switch from=$order.ship_status}>
        <{case value='0'}><{t}>[未发货]<{/t}>
        <{case value='1'}><{t}>[已发货]<{/t}>
        <{case value='2'}><{t}>[部分发货]<{/t}>
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{/switch}>
        <{case value='5'}><{t}>已退款<{/t}>
        <{switch from=$order.ship_status}>
        <{case value='0'}><{t}>[未发货]<{/t}>
        <{case value='1'}><{t}>[已发货]<{/t}>
        <{case value='2'}><{t}>[部分发货]<{/t}>
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{/switch}>
        <{case}>
         <!--普通订单-->
        <{if $order.promotion_type != 'prepare'}>
          <{if $order.payinfo.pay_app_id != '-1'}><a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>"><{/if}><{t}><{if $order.payinfo.pay_app_id == 'offline'}>等待发货<{else}>等待付款<{/if}><{/t}><{if $order.payinfo.pay_app_id != '-1'}></a><{/if}>
        <{/if}>
        <!--预售订单-->
         <{if $order.promotion_type == 'prepare'}>
          <{if $order.payinfo.pay_app_id != '-1'}><a href="#"><{/if}><{t}><{if $order.payinfo.pay_app_id == 'offline'}>等待发货<{else}>等待付款<{/if}><{/t}><{if $order.payinfo.pay_app_id != '-1'}></a><{/if}>
        <{/if}>
        <{switch from=$order.ship_status}>
        <{case value='1'}><{t}>[已发货]<{/t}>
	<{switch from=$order.received_status}><!--add by wenlong-->
        <{case value='1'}><{t}>[已收货]<{/t}><!--add by wenlong-->
        <{/switch}><!--add by wenlong-->
        <{case value='2'}><{t}>[部分发货]<{/t}>
	<{switch from=$order.received_status}><!--add by wenlong-->
        <{case value='2'}><{t}>[部分收货]<{/t}><!--add by wenlong-->
        <{/switch}><!--add by wenlong-->
        <{case value='3'}><{t}>[部分退货]<{/t}>
        <{case value='4'}><{t}>[已退货]<{/t}>
        <{/switch}>
        <{/switch}>
        <{/switch}>
      </td>
      <td class="payments"><{$order.payinfo.pay_app_id|pay_name}></td>
      <td class="actions" valign="top"<{if $is_orders}> rowspan="2"<{/if}>>
        <!--普通订单-->
        <{if $order.status == 'active' && ($order.pay_status=='0' || $order.pay_status=='3') && $order.promotion_type != 'prepare'&& $order.payinfo.pay_app_id != 'offline'}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==0}>
          <a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>" class="btn btn-import"><span><span><{t}>去付款<{/t}></span></span></a>
          <{/if}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==1}>
          <a href="javascript:void(0);" onclick="js_method()" class="btn btn-grayed"><span><span><{t}>支付结果返回中<{/t}></span></span></a>
          <{/if}>
        <{/if}>

        <!--预售订单-->
        <{if $order.status == 'active' && $order.pay_status=='0' && $order.promotion_type == 'prepare' && $order.prepare.status=='true' && $order.prepare.begin_time < $order.prepare.nowtime &&  $order.prepare.nowtime < $order.prepare.end_time}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==0}>
          <a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>" class="btn btn-import"><span><span><{t}>去付订金<{/t}></span></span></a>
          <{/if}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==1}>
          <a href="javascript:void(0);" onclick="js_method()" class="btn btn-grayed"><span><span><{t}>支付结果返回中<{/t}></span></span></a>
          <{/if}>
        <{/if}>
        <!--预售订单-->
        <{if $order.status == 'active' && $order.pay_status=='3' && $order.promotion_type == 'prepare' && $order.prepare.status=='true' && $order.prepare.begin_time_final < $order.prepare.nowtime &&  $order.prepare.nowtime < $order.prepare.end_time_final}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==0}>
          <a href="<{link app=b2c ctl=site_paycenter arg0=$order.order_id}>" class="btn btn-import"><span><span><{t}>去付尾款<{/t}></span></span></a>
          <{/if}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==1}>
          <a href="javascript:void(0);" onclick="js_method()" class="btn btn-grayed"><span><span><{t}>支付结果返回中<{/t}></span></span></a>
          <{/if}>
        <{/if}>
        <!--预售订单-->
        <{if $order.status == 'active' && $order.pay_status=='3' && $order.promotion_type == 'prepare' && $order.prepare.status=='true' && $order.prepare.begin_time < $order.prepare.nowtime &&  $order.prepare.nowtime < $order.prepare.begin_time_final}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==1 }>
          <a href="javascript:void(0);" onclick="js_method()" class="btn btn-grayed"><span><span><{t}>支付结果返回中<{/t}></span></span></a>
          <{elseif $order.payinfo.pay_app_id != '-1' }>
          <a href="#" class="btn btn-import"><span><span><{t}>等待支付尾款<{/t}></span></span></a>
          <{/if}>
        <{/if}>

        <{if $order.status == 'active' && $order.pay_status!='1' && $order.promotion_type == 'prepare' && $order.prepare.status=='true' &&  $order.prepare.nowtime > $order.prepare.end_time_final}>
          <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==1 }>
          <span><span><{t}>支付结果返回中<{/t}></span></span>
          <{elseif $order.payinfo.pay_app_id != '-1' }>
          <span><span><{t}>支付尾款时间已过,请联系管理员进行退款<{/t}></span></span>
          <{/if}>
        <{/if}>
        <{if $order.status != 'dead' && $order.status != 'finish' && $order.ship_status =="1" && ($order.received_status =='0' || $order.received_status == '2') && $order.ship_receive_status == 'ship'}>
          
        <!--=======================================================================================================================-->
          
          <a href="javascript:void(0);" class="btn btn-import" onclick="return receive('<{$order.url}>')"><span><span><{t}>确认收货<{/t}></span></span></a>
        <{/if}> 
        <{if $order.status != 'dead' && $order.status != 'finish' && $order.ship_status =="2" && ($order.received_status =='0' || $order.received_status == '2') && $order.ship_receive_status == 'ship'}> <!--modified by wenlong-->
          <a href="javascript:void(0);" class="btn btn-import" onclick="return receive('<{$order.url2}>')"><span><span><{t}>确认部分收货<{/t}></span></span></a><!--add by wenlong-->
        <{/if}>
        <{if $order.status != 'dead' && $order.status != 'finish' && $order.ship_status =="2" && $order.received_status =='2' && $order.ship_receive_status == 'receive'}>
          <a href="javascript:void(0);" class="btn btn-import disabled" onclick="error_show()"><span><span><{t}>确认收货<{/t}></span></span></a><!--modified by wenlong-->
        <{/if}>
        <!--=======================================================================================================================-->
        
        <i class="separator"></i><a href="<{link app=b2c ctl=site_member act=orderdetail arg0=$order.order_id arg1=$archive}>"><{t}>查看订单<{/t}></a>
        
        <{if $order.status == 'active' && $order.pay_status == '0' && $order.ship_status == '0' && $order.promotion_type != 'prepare' && $order.payinfo.pay_app_id != 'offline'}>
        <{if $order.is_pay == 0}>
        <i class="separator"></i><a class="btn-cancel" href="<{link app=b2c ctl=site_member act=cancel arg0=$order.order_id arg1=$archive}>"><{t}>取消订单<{/t}></a>
        <{/if}>
        <{else}>
        <i class="separator"></i><a href="<{link app=b2c ctl=site_member act=reAddCart arg0=$order.order_id arg1=$archive}>"><{t}>再次购买<{/t}></a>
        <{if $order.status == 'dead'}>
        <i class="separator"></i>
        <a href="javascript:if(confirm('删除以后将不会再看到该订单，是否继续？')) location='<{link app=b2c ctl=site_order act=dodelete arg0=$order.order_id}>'">
          <{t}>删除订单<{/t}></a>
        <{/if}>
        <{/if}>
       <!--  <{if $order.is_aftersales == true}>
        <i class="separator"></i><a href="<{link app=aftersales ctl=site_member act=add arg0=$order.order_id}>"><{t}>申请售后服务<{/t}></a>
        <{/if}> -->


      </td>
    </tr>
    <tr class="goods-row">
      <td colspan="5">
        <!--<ul class="member-piclist">-->
          <!--<{if $order.goods_items}>-->
          <!--<{foreach from=$order.goods_items item=item_goods name=goods_item}>-->
          <!--&lt;!&ndash;goods&ndash;&gt;-->
          <!--<{if $item_goods.product}>-->
          <!--<li class="goods-item">-->
            <!--<div class="goods-pic" data-tips="<{$item_goods.product.name}>&nbsp;<{if $item_goods.product.attr}><{$item_goods.product.attr|spec_desc}><{/if}>&nbsp;<{$item_goods.product.quantity}>">-->
              <!--<a href="<{$item_goods.product.link_url}>"><img src="<{$item_goods.product.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_goods.product.name}>&nbsp;<{$item_goods.product.attr}>" data-img-zoom="true"></a>-->
            <!--</div>-->
          <!--</li>-->
          <!--<{/if}>-->

          <!--&lt;!&ndash;adjunct&ndash;&gt;-->
          <!--<{if $item_goods.adjunct_items}>-->
          <!--<{foreach from=$item_goods.adjunct_items item=item_adjunct name=adjunct_item}>-->
          <!--<li class="goods-item">-->
            <!--<div class="goods-pic" data-tips="<{$item_adjunct.name}><{if $item_adjunct.attr}>&nbsp;<{$item_adjunct.attr}><{/if}>&nbsp;<{$item_adjunct.quantity}>">-->
              <!--<span class="label-important"><{t}>配<{/t}></span>-->
              <!--<a href="<{link app=b2c ctl=site_product act=index arg0=$item_adjunct.products.product_id}>"><img src="<{$item_adjunct.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_adjunct.name}> <{$item_adjunct.attr}>" data-img-zoom="true"></a>-->
            <!--</div>-->
          <!--</li>-->
          <!--<{/foreach}>-->
          <!--<{/if}>-->

          <!--&lt;!&ndash;gift&ndash;&gt;-->
          <!--<{if $item_goods.gift_items}>-->
          <!--<{foreach from=$item_goods.gift_items item=item_gift name=gift_item}>-->
          <!--<li class="goods-item">-->
            <!--<div class="goods-pic" data-tips="<{$item_gift.name}>&nbsp;<{if $item_gift.attr}><{$item_gift.attr}><{/if}>&nbsp;<{$item_gift.quantity}>">-->
              <!--<span class="label-important"><{t}>赠<{/t}></span>-->
              <!--<a href="<{$item_gift.link_url}>"><img src="<{$item_gift.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_adjunct.name}> <{$item_adjunct.attr}>" data-img-zoom="true"></a>-->
            <!--</div>-->
          <!--</li>-->
          <!--<{/foreach}>-->
          <!--<{/if}>-->
          <!--<{/foreach}>-->
          <!--<{/if}>-->
          <!--&lt;!&ndash; gift &ndash;&gt;-->
          <!--<{if $order.order.gift_items}>-->
          <!--<{foreach from=$order.order.gift_items item=item_gift name=gift_item}>-->
          <!--<li class="goods-item">-->
            <!--<div class="goods-pic" data-tips="<{$item_gift.name}>&nbsp;<{if $item_gift.attr}><{$item_gift.attr}><{/if}>&nbsp;<{$item_gift.quantity}>">-->
              <!--<span class="label-important"><{t}>赠<{/t}></span>-->
              <!--<a href="<{$item_gift.link_url}>"><img src="<{$item_gift.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_adjunct.name}> <{$item_adjunct.attr}>" data-img-zoom="true"></a>-->
            <!--</div>-->
          <!--</li>-->
          <!--<{/foreach}>-->
          <!--<{/if}>-->
          <!--<{if $order.gift.gift_items}>-->
          <!--<{foreach from=$order.gift.gift_items item=item_gift name=gift_item}>-->
          <!--<li class="goods-item">-->
            <!--<div class="goods-pic" data-tips="<{$item_gift.name}>&nbsp;<{if $item_gift.attr}><{$item_gift.attr}><{/if}>&nbsp;<{$item_gift.quantity}>">-->
              <!--<span class="label-important"><{t}>赠<{/t}></span>-->
              <!--<a href="<{$item_gift.link_url}>"><img src="<{$item_gift.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item_adjunct.name}> <{$item_adjunct.attr}>" data-img-zoom="true"></a>-->
            <!--</div>-->
          <!--</li>-->
          <!--<{/foreach}>-->
          <!--<{/if}>-->

          <!--&lt;!&ndash; extends &ndash;&gt;-->
          <!--<{if $order.extends_items}>-->
          <!--<{foreach from=$order.extends_items item=item_extends name=item_extends}>-->
          <!--<{$item_extends}>-->
          <!--<{/foreach}>-->
          <!--<{/if}>-->
        <!--</ul>-->
      </td>
    </tr>
  </tbody>
  <{/foreach}>
  <{else}>
  <tbody class="first">
    <tr class="no-information"><td colspan="6">暂无订单</td></tr>
  </tbody>
  <{/if}>
</table>
<script>
function receive(url){
	var msg = '是否确认收货？';
	 Dialog.confirm(msg, 
	function(e){
		 if(e){
			 var pingRequest = new Request({ 
				    method: "post", 
				    url:    url, 
				    onSuccess:  function(rs){
				      rs = JSON.decode(rs);
				      if(rs){
				        if(rs.error){
				          Dialog.alert(rs.error);
				          return false;
				        }else{
				          Dialog.alert(rs.success, {
				            onClose: function() {
				              location.reload();
				            }
				          });
				          return true;
				        }
				      }else{
				        return false;
				      }
				    }
				    }); 
				  pingRequest.send("url="+ url);
		 }
     }.bind(this)
	 );	
}
function error_show(){
  Dialog.alert("亲，您的商品还没发完呢");
}
//********add by wenlong**********
//合并付款按钮，跳转至付款页面
function pay_total(){
id=document.getElementsByName("id");
j=0;
var id_arr= [];
for(i=0;i<id.length;i++)
{
	if(id[i].checked)
	{
		id_arr+=id[i].value;
	//	j++;
	}
}
if(id_arr!='')
{
  window.location.href = "paycenter-"+id_arr+".html";
}
}

//全选复选框
onload = function ()
{
	var obox = document.getElementById ("box");
	var ach = document.getElementsByName ("id");
	//设置全选按钮选中的时候，遍历选中所有子复选框
	obox.onclick = function ()
	{
		for ( var i = 0; i < ach.length; i++)
		{
			ach[i].checked = this.checked;
		}
	}
	//子复选框有一个未选中时，去掉全选按钮的选中状态
	for ( var i = 0; i < ach.length; i++)
	{
		ach[i].onclick = function ()
		{
			if ( !this.checked )
			{
				obox.checked = false;
			}
		}
	}
}
//********************************
</script>
